package listener;

import data.User;
import protocal.DataPackage;
import protocal.DataPackage.MessageType;
import ui.ChatFrame;

public class ChatFrameListener extends Listener {
	
	private ChatFrame chatFrame;
	private Listener listener;
	
	public ChatFrameListener(ChatFrame chatFrame,Listener listener){
		this.chatFrame = chatFrame;
		this.listener = listener;
	}

	@Override
	public void listen(DataPackage dataPackage) {
		listener.listen(dataPackage);
		if (dataPackage.getMessageType()==MessageType.SHAKE&&(dataPackage.getToName().equals(User.name)||dataPackage.getToName().equals("\\"))) {
			chatFrame.shake();
		}

	}

}
